﻿[IconFile("GamePack.png")]

import com.gamepackage.audio.*;
import com.gamepackage.comp.*;
import com.gamepackage.events.*;
import com.gamepackage.util.*;

dynamic class com.gamepackage.comp.GamePack extends MovieClip
{
	/* STATIC PROPERTIES
	* *
	*/
	static private var instance: MovieClip;
	static private var depth: Number = 1;
	
	/* STATIC METHODS
	* *
	*/

	static function createGPackage( name: String ): Void
	{
		GamePack[ name ] = new GPackage( instance.createNewClip() );
	}
	
	/* INSTANCE
	* * */

	[Inspectable(defaultValue=true,false)]
	private var showFPS: Boolean;
	
	private var fps: TextField;
	
	private function GamePack()
	{
		if ( instance ) return;
		
		Impuls.initialize( instance = this );
		
		if ( showFPS ) displayFPS();
	}
	
	private function onLoad(): Void
	{
		this._parent.main();
	}
	
	function createNewClip( Void ): MovieClip
	{
		return createEmptyMovieClip( "__gp_clip__" + depth , depth++ );
	}
	
	private function displayFPS( Void ): Void
	{
		createTextField( "fps" , 0 , 0 , 0 , 0 , 0 );
		
		fps.autoSize = true;
		fps.background = true;
		fps.backgroundColor = 0x000000;
		fps.border = true;
		fps.borderColor = 0xffff00;
		
		var tf: TextFormat = new TextFormat();

		tf.size = 10;
		tf.font = "Courier";
		tf.color = 0xffff00;
		
		fps.setNewTextFormat( tf );
		
		FPS.toTextField( fps );
	}
	
	static function get $version():String
	{
		return "0.01"
	}
}